package com.zmc.dynamic.shard.rule.service.Impl;

import com.zmc.dynamic.shard.constant.ShardingTablePrefixConstant;
import com.zmc.dynamic.shard.rule.service.AbstractShardingRuleService;
import com.zmc.dynamic.shard.rule.service.ShardingRuleService;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class OrderShardingRuleServiceImpl extends AbstractShardingRuleService {



    @Override
    protected Set<String> getTables(Collection<String> collection, String column, Collection<String> values) {
        Set<String> set = new HashSet<>();
        values.forEach(value -> {
            set.add(ShardingTablePrefixConstant.ORDER_PREFIX + (Integer.parseInt(value) % collection.size()));
        });
        return set;
    }
}
